package com.ajk.server.bkcontroller;

import java.security.Principal;
import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.ajk.server.controller.access.ArgIndexForPrintLog;
import com.ajk.server.model.Friends;
import com.ajk.server.model.query.FriendsQuery;
import com.ajk.server.model.response.ResultList;
import com.ajk.server.model.response.ResultObject;
import com.ajk.server.service.FriendsService;

@RequestMapping("/admin/friend")
@RestController
public class AdminFriendController {

	@Autowired
	FriendsService friendsService;

	/**
	 * 亲属列表
	 */
	@ArgIndexForPrintLog(indexes = { 0 })
	@RequestMapping(value = "/list/{userId}", method = RequestMethod.GET)
	public ResultList<Friends> findMyFriends(@PathVariable("userId") Integer userId,Integer startId, Integer endId, Integer start, Integer limit,
			Principal principal) {
		FriendsQuery query = new FriendsQuery();
		query.setUserId(userId);
		query.setLimit(0);
		List<Friends> friednds = friendsService.findFriendsByQuery(query);
		return new ResultList<>(friednds);
	}

	/**
	 * 亲友属性
	 */

	@ArgIndexForPrintLog(indexes = { 0 })
	@RequestMapping(value = "/{friendId}/profile", method = RequestMethod.GET)
	public ResultObject<Friends> friendProfile(@PathVariable("friendId") Integer friendId, Principal principal) {
		Friends friednds = friendsService.findFriendsById(friendId);
		return new ResultObject<>(friednds);
	}
}